#include<iostream> 
#include"Balance.h"
#include"BinarySearchTree.h"
#include<time.h>

void Avl_BST_sort(vector<Comparable> &_data)
{
	Tree<Comparable> tree1;
	for(auto iter=_data.begin();iter!=_data.end();iter++){
		insert(tree1,iter);
		AvlTree(iter);
	}
	_data.clear();
}

void Splay_BST_sort(vector<Comparable> &_data)
{
	Tree<Comparable> tree2;
	for(auto iter=_data.begin();iter!=_data.end();iter++){
		insert(tree2,iter);
		SplayTree(iter);
	}
	_data.clear();
}

int main()
{
   std::vector<int> num;
   srand((unsigned)time(NULL)); 
   int start,end,time1,time2; 
   
   for(int i = 0; i < 20 ;i++ )
   {
       int t=(rand()*20)+1;
       if(num[t].isEmpty())
           t=t-1;
       else
           num[t]=i;
   }
   
   start=clock();
   Avl_BST_sort(num);
   end=clock();
   time1=end-start;
   
   start=clock();
   Splay_BST_sort(num);
   end=clock();
   time2=end-start;
   
   std::cout<<time1<<endl;
   std::cout<<time2<<endl;
}


